package com.cdel.akka.chapter5;

import akka.actor.AbstractActor;
import akka.actor.Status;
import akka.japi.pf.ReceiveBuilder;

//这个actor负责调用Future例子中的ArticleParser的静态apply方法
public class ArticleParseActor extends AbstractActor {

	private ArticleParseActor() {
		receive(ReceiveBuilder.match(ParseArticle.class, x -> {
			ArticleParser
				.apply(x.htmlBody)
				.onSuccess(body -> sender().tell(body, self()))
				.onFailure(t -> sender().tell(new Status.Failure(t), self()));
		})
		.build());
	}

}